package com.weixu.fileconver.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.InputStream;

/**
 * 文件转换结果封装类
 * @Author weixu
 * @Date 2025/8/29
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ConvertResult {
    
    private InputStream inputStream;
    private String fileName;
    private String contentType;
    private long fileSize;
    private String originalFileName;
    private String targetFormat;
    
    /**
     * 获取文件的MIME类型
     * @param format 文件格式
     * @return MIME类型
     */
    public static String getContentType(String format) {
        switch (format.toLowerCase()) {
            case "pdf":
                return "application/pdf";
            case "doc":
                return "application/msword";
            case "docx":
                return "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
            case "xls":
                return "application/vnd.ms-excel";
            case "xlsx":
                return "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
            case "ppt":
                return "application/vnd.ms-powerpoint";
            case "pptx":
                return "application/vnd.openxmlformats-officedocument.presentationml.presentation";
            case "odt":
                return "application/vnd.oasis.opendocument.text";
            case "ods":
                return "application/vnd.oasis.opendocument.spreadsheet";
            case "odp":
                return "application/vnd.oasis.opendocument.presentation";
            case "rtf":
                return "application/rtf";
            case "txt":
                return "text/plain";
            case "html":
                return "text/html";
            case "csv":
                return "text/csv";
            default:
                return "application/octet-stream";
        }
    }
}